package cn.edu.cqupt.cxcy.action;

import java.io.IOException;
import java.util.List;

import javax.servlet.ServletException;
import javax.servlet.http.HttpServlet;
import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;
import javax.servlet.http.HttpSession;

import cn.edu.cqupt.cxcy.dto.TeamImpl;

/**
 * 团队后台主页
 * @author Dancer-mno
 * @date 2015年10月17日
 */
public class TeamIndex extends HttpServlet {
	private static final long serialVersionUID = 1L;
	
	@Override
	protected void doGet(HttpServletRequest request, HttpServletResponse response) throws ServletException, IOException {
		this.doPost(request, response);
	}
	
	@Override
	protected void doPost(HttpServletRequest request, HttpServletResponse response) throws ServletException, IOException {
		response.setContentType("text/html;charset=utf-8");
		HttpSession session = request.getSession();
		List<Object> users = (List<Object>)session.getAttribute("user");
		int userId = (int)users.get(1);
		TeamImpl teamImpl = new TeamImpl();
		int count = teamImpl.getTeamMemberCount(userId);
		List<Object> members = teamImpl.showTeamMemberByList(userId);
		request.setAttribute("count", count);
		request.setAttribute("members", members);
		request.getRequestDispatcher("Tteam.jsp").forward(request, response);
	}

}
